<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>hybrid</title>
    <style>
      h2 {
        text-align: center;
      }
      button {
        margin-left: 3px;
        /* margin-top: 5px; */
      }
      .second {
        margin-top: 5px;
      }
    </style>
  </head>
  <body>
    <h2>hybrid 测试</h2>
    <button>打招呼</button>
    <button>获取用户信息</button>
    <button>删除用户信息</button>
    <button>更新用户信息</button><br />
    <button class="second">相机拍照</button>
    <button>相册选择图片</button>
    <button>传感器震动</button>
    <button>获取省市区</button>
    <!-- 引入调试控制台 -->
    <script src="node_modules/eruda/eruda.js"></script>
    <script>
      eruda.init();
    </script>
    <script>
      // document.querySelector("button").addEventListener("click", function () {
      //   // web网页中调用原生侧的方法
      //   console.log("测试 eruda 打印");
      //   mk.sayHi("~~ 惠风和畅 天晴朗 ~~");
      // });
      const btns = document.querySelectorAll("button");
      btns[0].addEventListener("click", function () {
        // web网页中调用原生侧的方法
        console.log("测试 eruda 打印");
        mk.sayHi("~~ 惠风和畅 天晴朗 ~~");
      });
      btns[1].addEventListener("click", function () {
        console.log(mk.queryUser());
      });
      btns[4].addEventListener("click", function () {
        try {
          mk.pickerCamera();
          console.log("相机拍照功能执行了");
        } catch (err) {
          console.error("pickerCamera error:" + err);
        }
      });
      btns[5].addEventListener("click", async function () {
        try {
          const res = await mk.pickerPhoto();
          console.log(res);
          console.log("相册服务执行了");
        } catch (err) {
          console.log("mk.pickerPhoto error:", err);
        }
      });
      btns[6].addEventListener("click", function () {
        try {
          mk.vibrator();
          console.log("马达震动执行了");
        } catch (err) {
          console.log("vibrator err:", err);
        }
      });
      btns[7].addEventListener("click", async function () {
        const res = await mk.getAreaColumns();
        console.log("省市区：", res);
      });
    </script>
  </body>
</html>
